﻿using Abp.Dependency;
using Abp.Domain.Repositories;
using Abp.Events.Bus.Entities;
using Abp.Events.Bus.Handlers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FwProject.Core.Car;
using Abp.Runtime.Caching;
using FwProject.Authorization.Users;
using Abp.RemoteEventBus;
using FwProject.Core.SettlementInfoModel;
using FwProject.Core.Restaurant;

namespace FwProject.Application.EventHandl
{
    public class UserHandle : IEventHandler<EntityChangedEventData<User>>,ITransientDependency
    {
        public readonly ICacheManager _catchmanager;
        public IRemoteEventBus remoteEventBus { get; set; }//缓存对象
        public UserHandle(ICacheManager catchmanager)
        {
            _catchmanager = catchmanager;
            remoteEventBus = NullRemoteEventBus.Instance;
        }
         /// <summary>
         /// 删除缓存
         /// </summary>
         /// <param name="eventData">Event data.</param>
        public void HandleEvent(EntityChangedEventData<User> eventData)
        {
            ICache cache = _catchmanager.GetCache(nameof(User));
            cache.Remove("list");

            cache = _catchmanager.GetCache(nameof(SettlementInfo));
            cache.Clear();
            cache = _catchmanager.GetCache(nameof(RestaurantUserInfo));
            cache.Clear();
            cache = _catchmanager.GetCache(nameof(RestaurantInfo));
            cache.Clear();
            cache = _catchmanager.GetCache(nameof(CarInfo));
            cache.Clear();

        }
    }
}
